﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:Dotway.WPF.Controls">

    <Style TargetType="{x:Type local:EditSlider}">       
        <Setter Property="VerticalAlignment" Value="Top" />
        <Setter Property="HorizontalAlignment" Value="Left" />
        <Setter Property="BorderBrush" Value="Black" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Background">
            <Setter.Value>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#FF505050" Offset="0"/>
                    <GradientStop Color="#FF373737" Offset="0.35"/>
                </LinearGradientBrush>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:EditSlider}">
                    <Border SnapsToDevicePixels="true" Background="{TemplateBinding Background}" 
                            BorderBrush="{TemplateBinding BorderBrush}" 
                            BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="5">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Rectangle x:Name="bar" Grid.Column="0" Width="{TemplateBinding ValuePosition}" RadiusX="5" RadiusY="5">
                                <Rectangle.Fill>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="#FF969696" Offset="0"/>
                                        <GradientStop Color="#FF6E6E6E" Offset="0.35"/>
                                    </LinearGradientBrush>
                                </Rectangle.Fill>
                            </Rectangle>
                            <TextBox x:Name="PART_TextBox" BorderBrush="Transparent" Foreground="White" BorderThickness="0" Background="{x:Null}" Grid.Column="0" Grid.ColumnSpan="2" IsReadOnly="true" Text="{Binding Path=Value, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" MinHeight="{TemplateBinding MinHeight}" />
                            <Rectangle x:Name="PART_InteractionShape" Grid.Column="0" Grid.ColumnSpan="2" Fill="Transparent"/>
                        </Grid>

                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsValueEditing" Value="True">
                            <Setter Property="FocusManager.FocusedElement" TargetName="PART_TextBox" Value="{Binding ElementName=PART_TextBox}"/>
                            <Setter Property="IsReadOnly" TargetName="PART_TextBox" Value="False"/>
                            <Setter Property="Background" TargetName="PART_TextBox" Value="Black"/>
                            <Setter Property="Fill" TargetName="PART_InteractionShape" Value="{x:Null}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="Orientation" Value="Vertical">
                <Setter Property="Background">
                    <Setter.Value>
                        <LinearGradientBrush EndPoint="1.0,0.5" StartPoint="0.0,0.5">
                            <GradientStop Color="#FF505050" Offset="0"/>
                            <GradientStop Color="#FF373737" Offset="0.35"/>
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type local:EditSlider}">
                            <Border SnapsToDevicePixels="true" Background="{TemplateBinding Background}" 
                            BorderBrush="{TemplateBinding BorderBrush}" 
                            BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="5">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="*" />
                                        <RowDefinition Height="Auto" />
                                    </Grid.RowDefinitions>

                                    <Rectangle x:Name="bar" Grid.Row="1" Height="{TemplateBinding ValuePosition}" RadiusX="5" RadiusY="5">
                                        <Rectangle.Fill>
                                            <LinearGradientBrush EndPoint="1.0,0.5" StartPoint="0.0,0.5">
                                                <GradientStop Color="#FF969696" Offset="0"/>
                                                <GradientStop Color="#FF6E6E6E" Offset="0.35"/>
                                            </LinearGradientBrush>
                                        </Rectangle.Fill>
                                    </Rectangle>
                                    <TextBox x:Name="PART_TextBox" BorderBrush="Transparent" BorderThickness="0" Background="{x:Null}" IsReadOnly="true" Text="{Binding Path=Value, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" Foreground="White" MinWidth="{TemplateBinding MinWidth}" RenderTransformOrigin="0.5,0.5" Grid.Row="0" Grid.RowSpan="2" VerticalAlignment="Bottom">
                                        <TextBox.LayoutTransform>
                                            <RotateTransform Angle="-90" />
                                        </TextBox.LayoutTransform>
                                    </TextBox>
                                    <Rectangle x:Name="PART_InteractionShape" Grid.Row="0" Grid.RowSpan="2" Fill="Transparent"/>
                                </Grid>

                            </Border>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsValueEditing" Value="True">
                                    <Setter Property="FocusManager.FocusedElement" TargetName="PART_TextBox" Value="{Binding ElementName=PART_TextBox}"/>
                                    <Setter Property="IsReadOnly" TargetName="PART_TextBox" Value="False"/>
                                    <Setter Property="Background" TargetName="PART_TextBox" Value="Black"/>
                                    <Setter Property="Fill" TargetName="PART_InteractionShape" Value="{x:Null}"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
        </Style.Triggers>
    </Style>

</ResourceDictionary>
